package bainuo
execute()
def execute() {
println(111111111111111111)
    def fff= testGetAccassToken.testEnv2()
    String appKey = "d42bf79ccfcd49fa8c001f15b208b8cd";
    String appSecret = "7c70c9c39e70300e3496770e9c5bbffb47280dfc";
    String openApiUrl = "https://srm.bestcomm.cn:11443";
    Map paramMap = new HashMap();
    paramMap.put("appKey", appKey);
    paramMap.put("appSecret", appSecret);
    paramMap.put("openApiUrl", openApiUrl);
    paramMap.put("businessType", "diwork_yuncai");
    paramMap.put("businessId", fff.get("field"));
    paramMap.put("usePrivateBucket", "true");
    paramMap.put("fileName", "contract.pdf");
    paramMap.put("fileBase64", fileToBase64(new File("D:\\2021-12-24\\WMS接口 - 副本.pdf")));
    Map uploadResult = BIPFormUtilTest.uploadFile(paramMap);
}
import com.yonyou.iuap.open.builder.OpenServiceBuilder
import com.yonyou.iuap.open.http.model.HttpResponse
import com.yonyou.iuap.open.invoke.InputParam
import com.yonyou.iuap.open.invoke.Invoke
import groovy.util.logging.Slf4j
import org.junit.Test

@Slf4j
class TestGetAccessToken2 {

    /**
     * 自建应用调用openapi
     */
    @Test
    void testEnv2() {
        runEnv2()
    }

    /**
     * 实际执行逻辑的方法
     */
    void runEnv2() {
        def map = [:]
        // map.put("id", "2153448052277379078") 如果需要可以取消注释并使用这行代码

        // 传入appKey和环境信息，主要用于获取accessToken
        def openServiceBuilder = new OpenServiceBuilder()
                .setAppKey("bb79e444132a4048987b3928b1ffc040") // 自建应用的appKey
                .setAppSecret("14b111022ac4eb6cf84df3e55e2c0f49f8d2cf8a") // 自建应用的appSecret
                .setEnv("https://srm.bestcomm.cn:11443") // 环境信息，传入统一域名即可

        // 传入openapi的相对地址和请求参数信息
        def inputParam = new InputParam()
                .setUrl("/yonbip/cpu/purchase/detail?id=2153448052277379078")
                .setContentType("application/json")
                .setMethod("GET")

        try {
            // 获取opanapi调用结果
            HttpResponse result = Invoke.getResult(openServiceBuilder, inputParam)
            log.info "${result.getStatusCode()}===${result.getResult()}"
        } catch (Exception e) {
            log.error "Error occurred while calling API", e
        }
    }

    // 如果你想从命令行运行这个类，可以保留main方法，并调用非测试方法。
    static void main(String[] args) {
        // 创建类的实例并调用非测试方法
        new TestGetAccessToken2().runEnv2()
    }
}
